<?php

/**
 * Discount filter form base class.
 *
 * @package    tsantek-shop
 * @subpackage filter
 * @author     Tomislav Šantek
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseDiscountFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'title'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'css_style'           => new sfWidgetFormFilterInput(),
      'link_text'           => new sfWidgetFormFilterInput(),
      'discount_by_percent' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'discount_by_price'   => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'slug'                => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'title'               => new sfValidatorPass(array('required' => false)),
      'css_style'           => new sfValidatorPass(array('required' => false)),
      'link_text'           => new sfValidatorPass(array('required' => false)),
      'discount_by_percent' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'discount_by_price'   => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'slug'                => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('discount_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Discount';
  }

  public function getFields()
  {
    return array(
      'id'                  => 'Number',
      'title'               => 'Text',
      'css_style'           => 'Text',
      'link_text'           => 'Text',
      'discount_by_percent' => 'Number',
      'discount_by_price'   => 'Number',
      'slug'                => 'Text',
    );
  }
}
